<?php
include_once($_SERVER['DOCUMENT_ROOT'] . '/htqlmba/models/m_taikhoan.php');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $nd = new taikhoan();
    $nd->setquyen($_SESSION['nmaquyen']);
    $nd->settendv($_SESSION['ntendv']);
    $nd->setmatkhau(md5(trim($_POST['txtmatkhauht'])));

    if ($nd->kiemTra()) {
        $matkhaumoi = md5(trim($_POST['txtmatkhaumoi1']));
        $nd->setmatkhau($matkhaumoi);
        $nd->suataikhoan();
        echo "<script language=javascript> alert('Đổi thành công!'); </script>";
        include_once("controls/c_logout.php");
    } else {
        echo "<script language=javascript> alert('Mật khẩu hiện tại không đúng!'); </script>";
        include_once('views/v_suamatkhau.php');
    }
} else
    include_once('views/v_suamatkhau.php');
?>
